package com.itheima.twodimensionarr;

public class TwoDimensionArrDemo03 {
    public static void main(String[] args) {
        /**
         * 第一季度：22, 66, 44
         * 第二季度：77, 33, 88
         * 第三季度：25, 45, 65
         * 第四季度：11, 66, 99
         * 要求算出每个嫉妒的总营业额和全年的总营业额
         */
        int[][] arr = {
                {22, 66, 44},
                {77, 33, 88},
                {25, 45, 65},
                {11, 66, 99}
        };
        int yearSum = 0;
        for (int i = 0; i < arr.length; i++) {
            int sum = getQuarterSum(arr[i]);
            System.out.println("第" + (i + 1) + "季度的营业额：" + sum);
            yearSum += sum;
        }
        System.out.println("总营业额：" + yearSum);
    }

    public static int getQuarterSum(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }
}
